# -*- coding: utf-8 -*-
# Copyright 2017-2019 ControlScan, Inc.
#
# This file is part of Cyphon Engine.
#
# Cyphon Engine is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# Cyphon Engine is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Cyphon Engine. If not, see <http://www.gnu.org/licenses/>.
#
# Generated by Django 1.10.1 on 2017-03-20 16:23
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import utils.validators.validators


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Collection',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40, validators=[utils.validators.validators.db_name_validator], verbose_name='collection name')),
            ],
            options={
                'ordering': ['warehouse', 'name'],
            },
        ),
        migrations.CreateModel(
            name='Warehouse',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('backend', models.CharField(choices=[('elasticsearch', 'elasticsearch'), ('mongodb', 'mongodb')], default='elasticsearch', max_length=40)),
                ('name', models.CharField(max_length=40, validators=[utils.validators.validators.db_name_validator, utils.validators.validators.lowercase_validator])),
                ('time_series', models.BooleanField(default=False, help_text="When used with Elasticsearch, stores each day's data in a separate index. Allows easy deletion of old data in Elasticsearch.")),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.AlterUniqueTogether(
            name='warehouse',
            unique_together=set([('backend', 'name')]),
        ),
        migrations.AddField(
            model_name='collection',
            name='warehouse',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='collections', related_query_name='collection', to='warehouses.Warehouse'),
        ),
        migrations.AlterUniqueTogether(
            name='collection',
            unique_together=set([('warehouse', 'name')]),
        ),
    ]
